package com.yanqu.road.server.manger.cricket;

import com.yanqu.road.entity.enums.eSkillType;
import com.yanqu.road.pb.cricket.CricketProto;
import com.yanqu.road.server.gameplayer.module.cricket.battle.CricketGame;
import com.yanqu.road.server.gameplayer.module.cricket.model.BattleData;
import com.yanqu.road.server.gameplayer.module.cricket.model.SkillData;
import com.yanqu.road.server.manger.cricket.skillhandler.attround.handler.CricketSkill400Strategy;
import com.yanqu.road.server.manger.cricket.skillhandler.attround.handler.CricketSkill401Strategy;
import com.yanqu.road.server.manger.cricket.skillhandler.startround.CricketSkillStartRoundStrategy;
import com.yanqu.road.server.manger.cricket.skillhandler.startround.handler.*;
import com.yanqu.road.server.manger.cricket.skillhandler.startround.handler.CricketSkill155Strategy;
import com.yanqu.road.server.manger.cricket.skillhandler.startround.handler.CricketSkill158Strategy;

import java.util.LinkedHashMap;
import java.util.Map;

public class CricketStartRoundSkillMgr {

    /**
     * 回合前，我方技能
     */
    private static Map<Integer, CricketSkillStartRoundStrategy> startRoundActionSkillMap = new LinkedHashMap<>();
    static {
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill145.getValue(), new CricketSkill145Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill151.getValue(), new CricketSkill151Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill155.getValue(), new CricketSkill155Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill158.getValue(), new CricketSkill158Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill163.getValue(), new CricketSkill163Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill167.getValue(), new CricketSkill167Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill259.getValue(), new CricketSkill259Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill255.getValue(), new CricketSkill255Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill253.getValue(), new CricketSkill253Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill150.getValue(), new CricketSkill150Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill152.getValue(), new CricketSkill152Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill156.getValue(), new CricketSkill156Strategy());
        startRoundActionSkillMap.put(eSkillType.CricketBattleSkill409.getValue(), new CricketSkill409Strategy());
    }
    /**
     * 回合前，对方技能
     */
    private static Map<Integer, CricketSkillStartRoundStrategy> startRoundTargetSkillMap = new LinkedHashMap<>();
    static {
        startRoundTargetSkillMap.put(eSkillType.CricketBattleSkill260.getValue(), new CricketSkill260Strategy());
        startRoundTargetSkillMap.put(eSkillType.CricketBattleSkill408.getValue(), new CricketSkill408Strategy());
        startRoundTargetSkillMap.put(eSkillType.CricketBattleSkill405.getValue(), new CricketSkill405Strategy());
        startRoundTargetSkillMap.put(eSkillType.CricketBattleSkill401.getValue(), new CricketSkill401Strategy());
    }

    /**
     * 回合前-我方技能
     * @param cricketGame
     * @param skillData
     * @param action
     * @param target
     * @param roundId
     * @param attackRoundBuilder
     * @return bool true：退出技能处理，false：继续技能处理
     */
    public static boolean actionSkillHandle(CricketGame cricketGame, SkillData skillData, BattleData action, BattleData target, int roundId, CricketProto.CricketAttackRound.Builder attackRoundBuilder) {
        CricketSkillStartRoundStrategy cricketSkillStartRoundStrategy = startRoundActionSkillMap.get(skillData.getSkillEffect().getSkillType());
        if (cricketSkillStartRoundStrategy != null) {
            return cricketSkillStartRoundStrategy.skillHandle(cricketGame, skillData, action, target, roundId, attackRoundBuilder);
        }
        return false;
    }

    /**
     * 回合前-对方技能
     * @param cricketGame
     * @param skillData
     * @param action
     * @param target
     * @param roundId
     * @param attackRoundBuilder
     * @return bool true：退出技能处理，false：继续技能处理
     */
    public static boolean targetSkillHandle(CricketGame cricketGame, SkillData skillData, BattleData action, BattleData target, int roundId, CricketProto.CricketAttackRound.Builder attackRoundBuilder) {
        CricketSkillStartRoundStrategy cricketSkillStartRoundStrategy = startRoundTargetSkillMap.get(skillData.getSkillEffect().getSkillType());
        if (cricketSkillStartRoundStrategy != null) {
            return cricketSkillStartRoundStrategy.skillHandle(cricketGame, skillData, action, target, roundId, attackRoundBuilder);
        }
        return false;
    }
}
